package com.swh.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author: swh
 * @Description:
 * @Date: 2021/2/1 17:16
 * @Version: 1.0
 */
//@ComponentScan("com.swh")
@PropertySource(value = "classpath:abc.properties")
@Controller
public class WX {

    @Value("${wx.AppID}")
    private String appId;

    @Value("${wx.AppSecret}")
    private String appSecret;

    @Value("${wx.redirect_uri}")
    private String redirect_uri;



    @ResponseBody
    @RequestMapping("to_wxLogin")
    public void wx_login( HttpServletResponse response) throws IOException {



        String url="https://open.weixin.qq.com/connect/qrconnect?" +
                "appid=" +appId+
                "&redirect_uri=" +redirect_uri+
                "&response_type=code" +
                "&scope=snsapi_login"  ;

//        System.out.println(url);
        response.sendRedirect(url);

    }
}
